#define GLOG_NO_ABBREVIATED_SEVERITIES

#pragma once

#include <glog/logging.h>
#include <fstream>
#include <string>
#include <mutex>

class CustomLogSink : public google::LogSink {
public:
    CustomLogSink(const std::string& base_filename);

    void send(google::LogSeverity severity, const char* full_filename,
        const char* base_filename, int line,
        const struct ::tm* tm_time,
        const char* message, size_t message_len) override;

private:
    void UpdateLogFile();
    std::string GetCurrentTimeWithMilliseconds();

private:
    std::ofstream log_file_;
    std::string base_filename_;
    std::mutex mutex_;
    int last_day_ = -1;
};
